class EmpleadoLocalesController < ApplicationController
  # GET /empleado_locales
  # GET /empleado_locales.xml
  def index
    @empleado_locales = EmpleadoLocal.all(:include => [:empleado, :local]) if params[:empleado_id].nil? or params[:empleado_id].size == 0
    @empleado_locales = EmpleadoLocal.all(:conditions => ["empleado_id = ?", params[:empleado_id]], :include => [:empleado, :local]) if !params[:empleado_id].nil? and params[:empleado_id].size > 0
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @empleado_locales.to_xml(:include => [:empleado, :local]) }
    end
  end

  # GET /empleado_locales/1
  # GET /empleado_locales/1.xml
  def show
    @empleado_local = EmpleadoLocal.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @empleado_local }
    end
  end

  # GET /empleado_locales/new
  # GET /empleado_locales/new.xml
  def new
    @empleado_local = EmpleadoLocal.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @empleado_local }
    end
  end

  # GET /empleado_locales/1/edit
  def edit
    @empleado_local = EmpleadoLocal.find(params[:id])
  end

  # POST /empleado_locales
  # POST /empleado_locales.xml
  def create
    @empleado_local = EmpleadoLocal.new(params[:empleado_local])

    respond_to do |format|
      if @empleado_local.save
        flash[:notice] = 'EmpleadoLocal was successfully created.'
        format.html { redirect_to(@empleado_local) }
        format.xml  { render :xml => @empleado_local, :status => :created, :location => @empleado_local }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @empleado_local.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /empleado_locales/1
  # PUT /empleado_locales/1.xml
  def update
    @empleado_local = EmpleadoLocal.find(params[:id])

    respond_to do |format|
      if @empleado_local.update_attributes(params[:empleado_local])
        flash[:notice] = 'EmpleadoLocal was successfully updated.'
        format.html { redirect_to(@empleado_local) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @empleado_local.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /empleado_locales/1
  # DELETE /empleado_locales/1.xml
  def destroy
    @empleado_local = EmpleadoLocal.find(params[:id])
    @empleado_local.destroy

    respond_to do |format|
      format.html { redirect_to(empleado_locales_url) }
      format.xml  { head :ok }
    end
  end
end
